package sk.tramtatiri.pages.users;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import sk.tramtatiri.MySession;
import sk.tramtatiri.core.IConstants;
import sk.tramtatiri.data.dao.interfaces.FriendshipDao;
import sk.tramtatiri.data.dao.interfaces.UserDao;
import sk.tramtatiri.data.dataobjects.User;

public class MessagingPage extends UserPageTemplate {
 
	@SpringBean
	private FriendshipDao friendshipDao;
	
	private List<User> friendList = new ArrayList<User>();
	
	public MessagingPage() {
		friendList = friendshipDao.findAllFriendsOfUser(((MySession)getSession()).getUserID());
		
		add(new ListView<User>("userRow", friendList) {
		    protected void populateItem(ListItem item) {
		        final User user = (User) item.getModelObject();
		        item.add(new Label("userNick", user.getNickName()));
		    }
		});
	}
	
	@Override
	public String getPageTitle() {
		return IConstants.PAGE_NAME + " - Messaging";
	}

}
